const PROB_TABLE: [f64; 365] = prob_table();

const fn prob_table() -> [f64; 365] {
    let mut table = [0.0; 365];
    let mut i = 2;
    while i < 365 {
        table[i] = 1.0 - ((1.0 - table[i - 1]) * (365 - (i - 1)) as f64 / 365.0);
        i += 1;
    }
    table
}

pub fn new_birthday_probability(n: u32) -> f64 {
    (n < 365).then(|| PROB_TABLE[n as usize]).unwrap_or(1.0)
}
